/**
 * @author		chenc
 * @version		1.0
 * @date		2016.1.13
 *
 * @file		sct/rtspclient/rtspclientinterface.h
 * @brief		rtsp client interface
 *
 * CRTSPClientInterface
 */

#ifndef SCT_RTSPCLIENT_RTSPCLIENTINTERFACE_H
#define SCT_RTSPCLIENT_RTSPCLIENTINTERFACE_H

#include <stdint.h>
#include "../rtspserver/rtspserverinterface.h"

namespace sct
{
class CRTSPClientCallback;
class CRTSPClientInterface
{
public:
	class CBlockInfo
	{
	public:
		CRTSPServerInterface::Type type;

		int64_t pts;
		uint32_t drop_frame_pre;
	};

public:

	/**
	 * destroy the object
	 */
	virtual ~CRTSPClientInterface() {}

	/**
	 * create a object
	 *
	 * thread unsafe
	 *
	 * @param name[in]  should be "rtspclient"
	 */
	static CRTSPClientInterface* create(const char * name);

	/**
	 * recv data from network. and demux
	 *
	 * you must run this function repeatly, fastly, \n
	 * if you want this lib work right.
	 */
	virtual int demux() {return 0;}

	/**
	 * reset the client
	 *
	 * this function will set the state machine to the init state.\n
	 * the data which received, will lost then.
	 */
	virtual void reset() {}

	/**
	 * set the buffer max delay
	 *
	 * when the buffer delay over it, it will drop data to keep the max delay.\n
	 * the default value is 3000000us
	 *
	 * @param delay microsecond
	 *
	 */
	virtual void setMaxDelay(const int64_t delay) {}

	/**
	 * set target URL
	 *
	 * the server URL which will be received data from.
	 */
	virtual void setServerUrl(const char * url) {}

	void addCallback(CRTSPClientCallback * callback) {mCallback = callback;}
	void delCallback(CRTSPClientCallback * callback) {mCallback = NULL;}

protected:
	/**
	 * the empty constructor
	 */
	CRTSPClientInterface():mCallback(NULL) {}

protected:
	CRTSPClientCallback* mCallback;
};

class CRTSPClientCallback
{
	friend class CRTSPClientInterface;
public:
	virtual ~CRTSPClientCallback(){}

	virtual void onRecvData(CRTSPClientInterface* caller, const void* d,
			const int len,
			const CRTSPClientInterface::CBlockInfo & info){}
};

}//end namespace

#endif
